﻿using System;
using System.Collections.Generic;
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using MyHotel_DTO;
using MyHotel_Common;

namespace MyHotel_DAO
{
    public class ChiTietPhieuThuePhongDAO :DAO
    {
        protected override object createObjectFromDatarow(DataRow row)
        {
            ChiTietPhieuThuePhong chitietphieuthuephong = new ChiTietPhieuThuePhong();
            chitietphieuthuephong.MaCTPT = Convert.ToInt32(row["MaCTPT"]);
            chitietphieuthuephong.MaPhieu = Convert.ToInt32(row["MaPhieu"]);
            chitietphieuthuephong.MaKH = Convert.ToInt32(row["MaKH"]);
            return chitietphieuthuephong;
        }
        

        public List<ChiTietPhieuThuePhong> getList()
        {
            List<ChiTietPhieuThuePhong> listchitietphieuthuephong = new List<ChiTietPhieuThuePhong>();
            string nameProc = "SP_LOAIPHONG_GETLIST";
            DataTable dt = DataProvider.executeStoreProcedureQuery(nameProc, null);
            return getListFromDataTable<ChiTietPhieuThuePhong>(dt);
        } 
        public int themChiTietPhieuThue(ChiTietPhieuThuePhong chitietPTT)
        {
            string nameProc = "them_ctpthue";
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@maphieu", chitietPTT.MaPhieu);
            para[1] = new SqlParameter("@makh", chitietPTT.MaKH); 
            return DataProvider.executeStoreProcedureNonQuery(nameProc, para);
        }
    }
}
